import {
  ChangeGovernanceStateParam,
  CreateGovernancePageParam,
  DeleteGovernancePageParam,
  EditGovernancePageParam,
  getScenarioListParam,
  GouvernanceResult,
  GovernanceDetailItem,
  GovernancePageParam,
  ScenarioItem,
  ViewGovernancePageParam,
} from './model/governanceModel';

import { maintenanceHttp } from '/@/utils/http/axios';

enum Api {
  GET_GOVERNANCE_LIST = '/v1/maintenance/serviceGovern/getList',
  GET_SCENARIO_LIST = '/v1/maintenance/serviceGovern/scenarioList',
  CREATE_GOVERNANCE = '/v1/maintenance/serviceGovern/create',
  EDIT_GOVERNANCE = '/v1/maintenance/serviceGovern/update',
  VIEW_GOVERNANCE = '/v1/maintenance/serviceGovern/detail',
  CHANGE_GOVERNANCE = '/v1/maintenance/serviceGovern/changeStatus',
  DELETE_GOVERNANCE = '/v1/maintenance/serviceGovern/delete',
}

export const getGovernanceList = (params: GovernancePageParam) => {
  // 获取策略列表
  return maintenanceHttp.get<GouvernanceResult>({
    url: Api.GET_GOVERNANCE_LIST,
    params,
  });
};

export const createGovernance = (params: CreateGovernancePageParam) => {
  // 创建治理策略
  return maintenanceHttp.post<string>({ url: Api.CREATE_GOVERNANCE, params });
};

export const editGovernance = (params: EditGovernancePageParam) => {
  // 编辑治理策略
  return maintenanceHttp.post<string>({ url: Api.EDIT_GOVERNANCE, params });
};

export const viewGovernance = (params: ViewGovernancePageParam) => {
  // 查看治理策略
  return maintenanceHttp.get<GovernanceDetailItem>({
    url: Api.VIEW_GOVERNANCE,
    params,
  });
};

export const changeGovernance = (params: ChangeGovernanceStateParam) => {
  // 状态
  return maintenanceHttp.get<string>({ url: Api.CHANGE_GOVERNANCE, params });
};

export const deleteGovernance = (params: DeleteGovernancePageParam) => {
  // 删除治理策略
  return maintenanceHttp.get<string>({ url: Api.DELETE_GOVERNANCE, params });
};

export const getScenarioList = (params: getScenarioListParam) => {
  // 获取场景列表 - 请求参数 - 治理类型'
  return maintenanceHttp.get<ScenarioItem[]>({
    url: Api.GET_SCENARIO_LIST,
    params,
  });
};
